from turbogears.widgets import *
from turbogears import validators

from actionflow.model import Project, Task, ProjectNote, TaskNote, Context

def get_project_options():
    option_list=[]
    for project in Project.select(Project.q.completed==False):
        option_list.append((project.id, project.name))
    return option_list    

class TaskFormFields(WidgetsList):
    name = TextField(validator=validators.NotEmpty)
    descripton = TextArea()
    context = AutoCompleteField(search_controller="/search_context",
                                 search_param = "search",
                                 search_name= "contexts")
    project = AutoCompleteField(search_controller = "/search_project", 
                                search_param = "search", 
                                result_name = "projects")
    completed = CheckBox(validator = validators.Bool)
    
task_form=TableForm(fields=TaskFormFields())

class ProjectFormFields(WidgetsList):
    name= TextField(validator = validators.NotEmpty)
    descripton = TextArea()

class ContextForm(WidgetsList):
    pass
    
